<?php
namespace app\shop\controller;
use x\Xbase;
use x\Container;
class Base extends Xbase{
    public $userinfo = [];
    public $com = [];
    public $sys = [];
    public $goodscat = [];
    public function __construct(){
        parent::__construct();
        if(is_post()){
            //err("商家后台暂未开放,请使用平台后台");
        }
        clear_cookie_arr('js');
        $this->_sys();
        $this->_user();
        $this->checkLogin();
    }

    //验证登陆
    public function _user(){
        $shop = m('Shop','c');
        $this->userinfo = $shop->isLogin();
        $this->assign('userinfo',$this->userinfo);
    }

    //通用
    public function _sys(){
        $this->sys = m('Deploy','xcom')->lists();
        $this->assign('sys',$this->sys);
        $this->assign('m',$this->m);
        $this->assign('c',$this->c);
        $this->assign('a',$this->a);

        $img = $this->db->cache("select * from img");
        foreach ($img as $key => $val) {
            $img[$val['uuid']] = $val;
            unset($img[$key]);
        }
        $this->com['img'] = $img;
        $word = $this->db->cache("select * from word");
        foreach ($word as $key => $val) {
            $word[$val['uuid']] = $val;
            unset($word[$key]);
        }
        $this->com['word'] = $word;
        $this->assign('com',$this->com);
    }

    //验证登录
    public function checkLogin(){
        if($this->c=='publics')
            return true;

        if(!$this->userinfo){
            if(is_ajax()){
                err('请先登录!');
            }else{
                r(url('publics/login'));
            }
        }
    }

}
